<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

class Fpt_Global
{

    private static $configuration = NULL;

    /**
     * Store DB connection
     * @var array 
     */
    private static $arrStorage = array();

    /**
     * store config ini
     * @var type 
     */
    private static $_configs = array();
    /**
     * store all memcache instance
     * @var type 
     */
    private static $_memcaches = array();
    private static $jobClient = array();
    /**
     * store all redis instance
     * @var type 
     */
    private static $_redis = array();
    /**
     * store all key cache
     * @var type 
     */
    private static $_cacheConfig = array();

	/**
     * Email instance
     * @var Fpt_Email
     */
    private static $emailInstance = null;

    /**
     * slide photo data
     */
	public static $slidePhoto = null;

    /**
     * prefix cache
     * @var <type>
     */
    private static $prefixCache = null;

    /**
     * Get DB connection
     * @return type 
     */
    public static function getDB($dbname = 'sport', $type = 'master')
    {
        try
        {
            //Get Ini Configuration
            if (is_null(self::$configuration))
            {
                self::$configuration = self::getApplicationIni();
            }

            //Set UTF-8 Collate and Connection
            $options_storage = self::$configuration['database'][ZONE_ENV][$dbname][$type];

            //Check size
            $index = 0;
            if (sizeof($options_storage) > 1)
            {
                //Get random number
                $keyRandom = Fpt_Utility::randomWord(10);

                //Get sharding
                $sharding = Fpt_Sharding::getInstance(
                                array(
                                    'adapter' => 'naive',
                                    'naive' => $options_storage
                                ));

                //Get configuration
                $options_storage = $sharding->getPartition($keyRandom, $index);

            } 
            else
            {
                $options_storage = $options_storage[$index];
            }

            //Set params
            if (empty($options_storage['params']['driver_options']))
            {
                $options_storage['params']['driver_options'] = array(
                    1002 => 'SET NAMES \'utf8\'',
                    12 => 0
                );
            }

            //Get storage instance
            if (!isset(self::$arrStorage[$dbname][$type][$index]))
            {
                //Create object to Connect DB
                self::$arrStorage[$dbname][$type][$index] = Zend_Db::factory($options_storage['adapter'], $options_storage['params']);

                //Changing the Fetch Mode
                self::$arrStorage[$dbname][$type][$index]->setFetchMode(Zend_Db::FETCH_ASSOC);

                //Create Adapter default is Db_Table
                Zend_Db_Table::setDefaultAdapter(self::$arrStorage[$dbname][$type][$index]);

                //clean
                unset($options_storage);
            }

            //Return storage
            return self::$arrStorage[$dbname][$type][$index];
        }
        catch (Exception $ex)
        {
            //log error
            Fpt_Log::sendlog(4, $ex->getCode(), $ex->getMessage(), $ex->getTraceAsString(), null, null);
            return false;
        }
    }

    /**
     * Get connection to DB Sport
     * @return Zend_Db_Adapter_Abstract
     */
    public static function getSportDB()
    {
        return self::getDB('sport', 'master');
    }

    /**
     * Get connection to slave DB Sport
     * @return Zend_Db_Adapter_Abstract
     */
    public static function getSportSlaveDB()
    {
        return self::getDB('sport', 'slave');
    }

    /**
     * Get connection to DB News
     * @return <Zend_Db>
     */
    public static function getNewsDB()
    {
        return self::getDB('news');
    }
    
    /**
     * Get connection to DB News
     * @return <Zend_Db>
     */
    public static function getNewsSlaveDB()
    {
        return self::getDB('news', 'slave');
    }

 
     /**
     * Get connection to DB Subpage
     * @return Zend_Db_Adapter_Abstract
     */
    public static function getSubpageDB()
    {
        return self::getDB('subpage', 'master');
    }

    /**
     * Get connection to master DB Suppage
     * @return Zend_Db_Adapter_Abstract
     */
    public static function getSubpageMasterDB()
    {
        return self::getDB('subpage', 'master');
    }

    /**
     * Get connection to slave DB Subpage
     * @return Zend_Db_Adapter_Abstract
     */
    public static function getSubpageSlaveDB()
    {
        return self::getDB('subpage', 'slave');
    }
    

    public static function mapKeys(array $arrItem, $strPrefix)
    {
        $arrValue = array();
        if (!is_array($arrItem))
        {
            $arrItem = array($arrItem);
        }
        foreach ($arrItem as $row)
        {
            $arrValue[$row] = $strPrefix . $row;
        }
        return $arrValue;
    }

    public static function makeCacheKey($cacheKey, $args = '')
    {
        //get key config 
        if(!isset(self::$_cacheConfig))
        {
            self::$_cacheConfig = Fpt_Global::getConfig('caching');
        }
        self::$_cacheConfig = Fpt_Global::getConfig('caching');
 
        //get prefix caching from config by key
        $format = self::$_cacheConfig[$cacheKey];
        //valid key
        if ($format != '')
        {
            if (!is_array($args))
            {
                return sprintf($format, $args);
            }
            $format = array($format);
            $args = array_merge($format, $args);
            return call_user_func_array("sprintf", $args);
        }
        return false;
    }

    /**
     * Get application application configuration
     * @return <object>
     */
    public static function getApplicationIni($config_key = '')
    {

        //Get Ini Configuration
        if (is_null(self::$configuration))
        {
            if (Zend_Registry::isRegistered(APP_CONFIG))
            {
                self::$configuration = Zend_Registry::get(APP_CONFIG);
            } 
            else
            {
                //Load and Registry general configuration
                $appConfigPath = APPLICATION_PATH . '/configs/application-' . APP_ENV . '.ini';
                $configuration = new Zend_Config_Ini($appConfigPath);
                self::$configuration = $configuration->toArray();
                Zend_Registry::set(APP_CONFIG, self::$configuration);
            }
        }
        if (!empty($config_key))
        {
            return self::$configuration->$config_key;
        }
        //Return data
        return self::$configuration;
    }

    /**
     *
     * @return array
     */
    public static function getConfigCache()
    {
        if (!isset(self::$arrStorage['cache']))
        {
            //Get Ini Configuration
            if (is_null(self::$configuration))
            {
                self::$configuration = Fpt_Global::getApplicationIni();
            }
            self::$arrStorage['cache'] = self::$configuration['cache'];
        }
        return self::$arrStorage['cache'];
    }

    public static function getConfig($filename, $module = '')
    {
        if (true || isset(self::$_configs[$module . '-' . $filename]))
        {

            $filepath = APPLICATION_PATH . '/' . 'configs' . '/';
            if (!empty($module))
            {
                $filepath.= $module . '/';
            }
            $filepath .= $filename . '-' . APP_ENV . '.ini';

            if (!isset(self::$_configs[$module . '-' . $filename])
                    && file_exists($filepath))
            {

                $config = new Zend_Config_Ini($filepath);
                self::$_configs[$module . '-' . $filename] = $config->toArray();
            }

        }
        return self::$_configs[$module . '-' . $filename];
    }
    //---------------Start get instance---------------//

    /**
     * Get Global caching instance
     * Sharding memcache instance by $shardingID
     * @param int $shardingID
     * @param string $idc idc prefix of this memcache instances. Ex: 'thethao'
     * @return mix success?Fpt_Cache:false 
     */
    public static function getMemcacheInstance($shardingID = 0, $zoneName = '', $idc = 'sport')
    {
        try
        {
            //Get Ini Configuration
            if (is_null(self::$configuration))
            {
                self::$configuration = self::getApplicationIni();
            }
            $shardingDB = 0;
            //init idc full
            $idcFull = $idc.$zoneName.'0';
            if(empty($zoneName))
            {
                $zoneName = ZONE_ENV;
            }
            if($shardingDB != 0)
            {
                //count total db
                $totalDB = count(self::$configuration['memcache'][$zoneName][$idc]);
                //check if need sharding db memcache
                if($totalDB > 1)
                {
                    //get sharding db from fw
                    $shardingDB = (!empty($shardingID))? Fpt_Sharding::getTableByID($shardingID, $totalDB):0;
                    //init idc full
                    $idcFull = $idc.$zoneName.$shardingDB;
                }
            }
            
            if (!isset(self::$_memcaches[$idcFull]))
            {
                //Get caching instance by db
                self::$_memcaches[$idcFull] = Fpt_Cache::getInstance(self::$configuration['memcache'][$zoneName][$idc][$shardingDB]);
            }
            //Return caching
            return self::$_memcaches[$idcFull];
        }
        catch (Exception $ex)
        {
            //log error
            Fpt_Log::sendlog(4, $ex->getCode(), $ex->getMessage(), $ex->getTraceAsString(), null, null);
            return false;
        }
    }

    public static function getRedisInstance($shardingDB = 0, $shardingID = 0, $idc = 'sport', $zoneName = '')
    {
        try
        {
            //Get Ini Configuration
            if (is_null(self::$configuration))
            {
                self::$configuration = self::getApplicationIni();
            }
            $zoneName = (!empty($zoneName))?$zoneName : ZONE_ENV;
            //check if we have to sharding INSTANCE
            if($shardingDB != 0)
            {
                //count total db
                $totalDB = count(self::$configuration['nosql'][ZONE_ENV][$idc]);
                //default sharding db
                $shardingDB = 0;
                //check if have to sharding
                if($totalDB > 1)
                {
                    //get sharding db from fw
                    $shardingDB = (!empty($shardingID))? Fpt_Sharding::getTableByID($shardingID, $totalDB):0;
                }
            }
 
            //init idc full
            $idcFull = $idc.$zoneName.$shardingDB;
            if (!isset(self::$_redis[$idcFull]))
            {
                self::$_redis[$idcFull] = Fpt_Nosql::getInstance(self::$configuration['nosql'][ZONE_ENV][$idc][$shardingDB]); 
            }
            
            $slotRedis = 0;
            //check if we have to sharding REDIS DB
            if($shardingID != 0)
            {
                $slotRedis = Fpt_Sharding::getTableRedisByID($shardingID, self::$configuration['nosql'][ZONE_ENV][$idc][$shardingDB]['redis']['totaldb']);
            }  
            //select redis db
            self::$_redis[$idcFull]->selectDb($slotRedis);
            //return redis storage
            return self::$_redis[$idcFull]->getStorage();
        }
        catch (Exception $ex)
        {
            //log error
            Fpt_Log::sendlog(4, $ex->getCode(), $ex->getMessage(), $ex->getTraceAsString(), null, null);
            return false;
        }
    }
    
    /**
     * get redis paging end
     * @param int $offset start: index if get range, scorestart if get score
     * @param int $limit end: index if get range, scoreend if get score
     * @param boolean $byScore
     * @param boolean $revert
     * @return type end 
     */
    public static function getRedisPaging($offset = 0, $limit = 10, $byScore = false, $revert = false)
    {
        if($byScore === true)
        {
            //when get by score:param limit mean: end score
            $end = $limit;
            
            if($limit == 0)
            {
                //get till the end of this list
                $end = '+inf';
            }
            if($offset == 0)
            {
                //get till the start of this list
                $offset = '-inf';
            }

            return array('startScore'=>$offset, 'endScore'=>$end);
        }
        if($limit == 0)
        {
            $end = '-1';
        }
        else if($limit == 1)
        {
            $end = ($offset == 0)? 0: $offset + $limit -1;
        }
        else
        {
            $end = ($limit>1)?($offset + $limit -1):($offset + $limit);
        }
        return $end;
    }
    
    
    /**
     * Get memcache sharding db by sharding db and total (this func is use to get multi)
     * @param int $shardingID
     * @param int $totalDB
     * @return mix success?int:false 
     */
    public static  function getMemcacheDB($shardingID, $totalDB)
    {
        try
        {
            return Fpt_Sharding::getTableByID($shardingID, $totalDB);
        }
        catch (Exception $ex)
        {
            //log error
            Fpt_Log::sendlog(4, $ex->getCode(), $ex->getMessage(), $ex->getTraceAsString(), null, null);
            return false;
        }
    }


    /**
     * Get memcache instance by db (exactly what instance => $shardingDB)
     * @param int $shardingDB
     * @param string $idc idc prefix of this memcache instances. Ex: 'thethao'
     * @return mix success?Fpt_Cache:false 
     */
    public static function getMemcacheInstanceByDB($shardingDB = 0 , $idc = 'thethao')
    {
        try
        {
            //Get Ini Configuration
            if (is_null(self::$configuration))
            {
                self::$configuration = self::getApplicationIni();
            }
            
            //init idc full
            $idc_full = $idc.$shardingDB;

            if (is_null(self::$_memcaches[$idc_full]))
            {
                //get config details
                $config = self::$configuration->caching->$idc->toArray();
                //Get caching instance by db
                self::$_memcaches[$idc_full] = Fpt_Cache::getInstance($config[$shardingDB]);
            }
            //Return caching
            return self::$_memcaches[$idc_full];
        }
        catch (Exception $ex)
        {
            //log error
            Fpt_Log::sendlog(4, $ex->getCode(), $ex->getMessage(), $ex->getTraceAsString(), null, null);
            return false;
        }
    }
    
    /**
     * Get job client
     * @return <Fpt_JobClient>
     */
    public static function getJobClientInstance($idc = 'sport')
    {
        try
        {
            //Get Ini Configuration
            if (is_null(self::$configuration))
            {
                self::$configuration = self::getApplicationIni();
            }

            //Get caching instance
            if (!isset(self::$jobClient[$idc]))
            {
                self::$jobClient[$idc] = Fpt_JobClient::getInstance(self::$configuration['job'][ZONE_ENV][$idc]);
            }

            //Return jobclient
            return self::$jobClient[$idc];
        }
        catch(Exception $ex)
        {
            //log error
            Fpt_Log::sendlog(4, $ex->getCode(), $ex->getMessage(), $ex->getTraceAsString(), null, null);
            return false;
        }
    } 

    /**
     * Get job function
     * @param string $idc idc name
     * @param <string> $name
     * @return <string>
     */
    public static function getJobFunction($idc, $funcname)
    {
        try
        {
            //Get Ini Configuration
            if(is_null(self::$configuration))
            {
                self::$configuration = self::getAppConfigurationIni();
            }

            //To array
            $jobConfiguration = self::$configuration['job'][ZONE_ENV][$idc];

            //Return job name
            return $jobConfiguration[$jobConfiguration['adapter']]['function'][$funcname];
        }
        catch(Exception $ex)
        {
            //log error
            Fpt_Log::sendlog(4, $ex->getCode(), $ex->getMessage(), $ex->getTraceAsString(), null, null);
            return false;
        }
    }
    
    
    //---------------START CLOSE RESOURCE---------------//
    /**
     * Close all db connection
     * @return <bool>
     */
    public static function closeAllDBInstance()
    {
        try
        {           
            if(isset(self::$arrStorage))
            {
                foreach (self::$arrStorage as $key => $dbName)
                {
                    foreach($dbName as $k => $types)
                    {
                        foreach($types as $storage)
                        {
                            //Try close
                            if (!is_null($storage))
                            {
                                if($storage->isConnected())
                                {
                                    $storage->closeConnection();
                                }
                            }
                        }
                    }
                }
                self::$arrStorage = null;
            }
            return true;
        }
        catch(Exception $ex)
        {
            //log error
            Fpt_Log::sendlog(4, $ex->getCode(), $ex->getMessage(), $ex->getTraceAsString(), null, null);
            return false;
        }   
    }

    /**
     * Close all caching instance
     */
    public static function closeAllCacheServer()
    {
        try
        {
            //Close all connection
            Fpt_Cache::closeAll();
            if(isset(self::$_memcaches)) 
            {
                //reset all memcache 
                self::$_memcaches = null;
            }
        } 
        catch(Exception $ex)
        {
            //log error
            Fpt_Log::sendlog(4, $ex->getCode(), $ex->getMessage(), $ex->getTraceAsString(), null, null);
            return false;
        }    
    }
    /**
     * Close all redis instance
     */
    public static function closeAllRedisServer()
    {
        try
        {
            //Close all connection
            Fpt_Nosql::closeAll();
            if(isset(self::$redis)) 
            {
                self::$redis = null;
            }
        }
        catch(Exception $ex)
        {
            //log error
            Fpt_Log::sendlog(4, $ex->getCode(), $ex->getMessage(), $ex->getTraceAsString(), null, null);
            return false;
        }    
    }
    
    /**
     * Get parent module params
     * @return <array>
     */
    public static function getParentParams()
    {
        
        //Check params
        if(Zend_Registry::isRegistered(PARENT_PARAMS_CONFIG))
        {
            
            return Zend_Registry::get(PARENT_PARAMS_CONFIG);
        }
        

        //Return default
        return array();
    }

    //---------------End CLOSE RESOURCE---------------//
    //---------------Start COMMON FUNCTION---------------//
    public function getArticleUrl($arrArticle = array(), $intPage = 1, $isEuro = false)
    {
        if ( $isEuro )
        {
            if ( substr($arrArticle['share_url'], 1, 5) == 'photo' )
            {
                $url = str_replace('/photo/', '/photo-euro/', $arrArticle['share_url']);
                return  substr($url,0,-5).'-'.$intPage.'.html';
            }
            elseif ( substr($arrArticle['share_url'], 1, 5) == 'video' )
            {
                return str_replace('/video/', '/video-euro/', $arrArticle['share_url']);
            }
            else
            {
                return $arrArticle['share_url'];
            }//end if
        }
        else
        {
            if(substr($arrArticle['share_url'],1,5)=='photo')
            {
                return  substr($arrArticle['share_url'],0,-5).'-'.$intPage.'.html';
            }
            else
            {
                return $arrArticle['share_url'];
            }
        }
    }
 
    /**
     * Set excluse arti
     * @param array $arrArticleIDs
     * @return array 
     * @author PhuongTN
     */
    public static function setExcluses($arrArticleIDs)
    {
        try
        {
            //set excluse
            $return = array();
            //check empty
            if(!empty($arrArticleIDs))
            {
                //Check registed
                if(Zend_Registry::isRegistered(EXCLUSE_ARTICLES))
                {
                    $return =  Zend_Registry::get(EXCLUSE_ARTICLES);
                }
                //merge array
                $return = array_merge($return, $arrArticleIDs);
                //set excluse
                Zend_Registry::set(EXCLUSE_ARTICLES, $return);
            }
        }
        catch(Exception $ex)
        {
            //log error
            Fpt_Log::sendlog(4, $ex->getCode(), $ex->getMessage(), $ex->getTraceAsString(), null, null);
        }
        return $return;
    }
    
    /**
     * Get excluse article
     * @return array 
     * @author PhuongTN
     */
    public static function getExcluses()
    {
        try
        {
            $return = array('total' => 0, 'data' => array());
            //Check params
            if(Zend_Registry::isRegistered(EXCLUSE_ARTICLES))
            {
                //get registry
                $rs = Zend_Registry::get(EXCLUSE_ARTICLES);
                if(!empty($rs))
                {
                    $return['total']    = count($rs);
                    $return['data']     = $rs;
                }
          
            }
        }
        catch(Exception $ex)
        {
            //log error
            Fpt_Log::sendlog(4, $ex->getCode(), $ex->getMessage(), $ex->getTraceAsString(), null, null);
        }
        return $return;
    }
    
    /**
     * delete memcache zones
     * @param int $shardingID
     * @param string $keyMemcache
     * @return boolean 
     * @author PhuongTN
     */
    public static  function deleteMemcache($shardingID, $keyMemcache)
    {
        try
        {
            //get application config
            $config     = Fpt_Global::getApplicationIni();
            //get all zoneNames
            $zoneNames  = array_keys($config['memcache']);
            
            if(!empty($zoneNames))
            {
                foreach($zoneNames as $zoneName)
                {
                    // Get instance memcache
                    $memcacheInstance = Fpt_Global::getMemcacheInstance($shardingID, $zoneName);

                    //Delete 1 key cache full only
                    $delRS = $memcacheInstance->delete($keyMemcache);
                }
            }
            return $delRS;
        }
        catch (Exception $ex)
        {
            //log error
            Fpt_Log::sendlog(4, $ex->getCode(), $ex->getMessage(), $ex->getTraceAsString(), null, null);
        }
        return false;
    }
    
    /**
     * write memcache
     * @param int $shardingID
     * @param string $keyMemcache
     * @param mix $data
     * @param int $expireTime
     * @return boolean 
     * @author PhuongTN
     */
    public static function writeMemcache($shardingID, $keyMemcache, $data = array(), $expireTime = 0)
    {
        try
        {
            //get application config
            $config     = Fpt_Global::getApplicationIni();
            
            //get all zoneNames
            $zoneNames  = array_keys($config['memcache']);
            
            if(!empty($zoneNames))
            {
                foreach($zoneNames as $zoneName)
                {
                    // Get instance memcache
                    $memcacheInstance = Fpt_Global::getMemcacheInstance($shardingID, $zoneName);
                    
                    //Delete 1 key cache full only
                    $writeRS = $memcacheInstance->write($keyMemcache, $data, $expireTime);
                }
            }
            return $writeRS;
        }
        catch (Exception $ex)
        {
            //log error
            Fpt_Log::sendlog(4, $ex->getCode(), $ex->getMessage(), $ex->getTraceAsString(), null, null);
        }
        return false;
    }
    /* Creating friendly UTF-8 Slug URLS
     * @param <string> $string
     * @param <int> $maxLength
     * @param <string> $separator
     * @return <tring> $url
     */
    public static function getSlug($string, $maxLength = 255, $separator = '-') {
        $string = Fpt_Filter::vnToAscii($string);
        $url = iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $string);
        $url = preg_replace("/[^a-zA-Z0-9\/_|+ -]/", '', $url);
        $url = trim(substr(strtolower($url), 0, $maxLength));
        $url = preg_replace("/[\/_|+ -]+/", $separator, $url);
        return $url;
    }
    //---------------Start BACKEND FUNCTION---------------//
    /**
     * from bb
     * Hàm chuyển đổi tiếng việt có dấu sang không dấu
     * @author Hoaptn
     * @modify nhuantp@fpt.net
     */
    function covertVN($str)
    {
        $str    = strip_tags($str);
        $str	= mb_strtolower($str, 'UTF-8');
        $str	= preg_replace('/(à|á|ạ|ả|ã|â|ầ|ấ|ậ|ẩ|ẫ|ă|ằ|ắ|ặ|ẳ|ẵ)/', 'a', $str);
        $str	= preg_replace('/(è|é|ẹ|ẻ|ẽ|ê|ề|ế|ệ|ể|ễ)/', 'e', $str);
        $str	= preg_replace('/(ì|í|ị|ỉ|ĩ)/', 'i', $str);
        $str	= preg_replace('/(ò|ó|ọ|ỏ|õ|ô|ồ|ố|ộ|ổ|ỗ|ơ|ờ|ớ|ợ|ở|ỡ)/', 'o', $str);
        $str	= preg_replace('/(ù|ú|ụ|ủ|ũ|ư|ừ|ứ|ự|ử|ữ)/', 'u', $str);
        $str	= preg_replace('/(ỳ|ý|ỵ|ỷ|ỹ)/', 'y', $str);
        $str	= preg_replace('/(đ)/', 'd', $str);
        $str	= preg_replace('/[^a-z0-9]/', '_', $str);
        return $str;
    }

    /**
     * Get user direct API
     * @return <object>
     */
    public static function getDirectOauth()
    {
        //Get Ini Configuration
        if(is_null(self::$configuration))
        {
            self::$configuration = self::getApplicationIni();
        }       

        //Return data
        return Fpt_OauthLogin::getInstance(self::$configuration['api']);
    }

    /**
     * Get user session API
     * @return <object>
     */
    public static function getUserLoginOauth()
    {
        //Get Ini Configuration
        if(is_null(self::$configuration))
        {
            self::$configuration = self::getApplicationIni();
        }
        

        //Return data
        return Fpt_OauthLogin::getInstance(
            array(
                'api_url'       =>  self::$configuration['api']['api_url'],
                'api_key'       =>  self::$configuration['api']['api_key'],
                'api_secret'    =>  self::$configuration['api']['api_secret'],
                'adapter'       =>  'user'
            )
        );
    }

    /**
     * Get connection to master DB Club
     * @return Zend_Db_Adapter_Abstract
     */
    public static function getClubMasterDB()
    {
        return self::getDB('club', 'master');
    }

    /**
     * Get connection to slave DB Club
     * @return Zend_Db_Adapter_Abstract
     */
    public static function getClubSlaveDB()
    {
        return self::getDB('club', 'slave');
    }

    /**
     * Get prefix caching
     * @return <string>
     */
    public static function getPrefixCaching($prefixName)
    {
        //Get Ini Configuration
        if ( is_null(self::$prefixCache) )
        {
            if ( Zend_Registry::isRegistered(GLOBAL_CACHING_CONFIG) )
            {
                self::$prefixCache  = Zend_Registry::get(GLOBAL_CACHING_CONFIG);
            }
            else
            {
                $cachingFile        = 'caching-'.APP_ENV.'.ini';
                self::$prefixCache  = new Zend_Config_Ini(APPLICATION_PATH.'/configs/'.$cachingFile);
                Zend_Registry::set(GLOBAL_CACHING_CONFIG, self::$prefixCache);
            }//end if
        }//end if

        //Return
        return (string) self::$prefixCache->$prefixName;
    }
}